#!/bin/bash
# 自动删除老CSV文件程序使用示例

echo "=== 自动删除老CSV文件程序演示 ==="
echo

echo "1. 查看帮助信息"
python3 auto_delete_old_files.py --help
echo
echo "================================"
echo

echo "2. 创建示例配置文件"
python3 auto_delete_old_files.py --create-config
echo

echo "3. 查看当前配置文件内容"
cat config.json
echo
echo "================================"
echo

echo "4. 模拟运行测试（不实际删除文件）"
echo "创建测试目录和文件..."
mkdir -p test_data
echo "test data" > test_data/20250501000000.csv
echo "test data" > test_data/20250501020000.csv
echo "test data" > test_data/20250501040000.csv
echo "test data" > test_data/20250501060000.csv

echo "模拟运行..."
python3 auto_delete_old_files.py --config config.json --target-directory test_data --once --dry-run
echo

echo "5. 查看测试目录内容"
ls -la test_data/
echo
echo "================================"
echo

echo "6. 实际运行（会删除文件）"
echo "执行文件删除..."
python3 auto_delete_old_files.py --config config.json --target-directory test_data --once
echo

echo "7. 查看删除后的目录内容"
ls -la test_data/
echo
echo "================================"
echo

echo "8. 创建生产环境配置文件示例"
cat > production_config.json << 'EOF'
{
  "settings": {
    "description": "生产环境自动删除老CSV文件配置",
    "version": "1.0"
  },
  "target_directory": "D:/works/water/data/file/local/1/1/1/5",
  "execution_time": "00:10:00",
  "file_pattern": "*.csv",
  "retention_days": 2,
  "log_enabled": true,
  "log_file": "./production_delete.log",
  "dry_run": false,
  "immediate_execution": false
}
EOF

echo "生产环境配置文件已创建: production_config.json"
echo "内容:"
cat production_config.json
echo

echo "9. 清理测试文件"
rm -rf test_data/
echo "测试完成！"
echo

echo "================================"
echo "使用说明:"
echo "- 修改config.json中的target_directory为你的实际目录"
echo "- 运行: python3 auto_delete_old_files.py"
echo "- 或者创建Windows批处理文件或Linux cron任务进行定时执行"
echo "- 使用--dry-run模式进行测试"
echo "================================"